<html>
<body>
<h2>Hello World!</h2>

<button id="addCourse">addCourse</button>
<button id="deleteCourse">deleteCourse</button>
<button id="modifyCourse">modifyCourse</button>
<button id="findCourse">findCourse</button>

</body>
</html>
<script src="https://cdn.bootcss.com/jquery/1.12.4/jquery.js"></script>
<script>
    window.onload = function () {
        $("#addCourse").click(function () {
            $.ajax({
                url : '/coursemgmt/courses',
                type : 'POST',
                async : false,
                contentType:"application/json",
                data : JSON.stringify({
                    "courseName": "cn1",
                    "syllabus": "sb1",
                    "courseware": "cw1"
                }),
                success : function(data) {
                    console.log(data);
                },
                error : function(returndata) {
                    console.log("error");
                }
            });
        })

        $("#deleteCourse").click(function () {
            $.ajax({
                url : '/coursemgmt/courses/cn1',
                type : 'DELETE',
                async : false,
                /*headers: {
                    "Content-Type": "application/json",
                    "X-HTTP-Method-Override": "DELETE"
                }, //PUT,DELETE*/
                success : function(data) {
                    console.log(data);
                },
                error : function(returndata) {
                    console.log("error");
                }
            });
        })

        $("#modifyCourse").click(function () {
            $.ajax({
                url : '/coursemgmt/courses',
                type : 'PUT',
                async : false,
                contentType:"application/json",
                data : JSON.stringify({
                    "courseName": "cn1",
                    "syllabus": "sb11",
                    "courseware": "cw11"
                }),
                success : function(data) {
                    console.log(data);
                },
                error : function(returndata) {
                    console.log("error");
                }
            });
        })

        $("#findCourse").click(function () {
            $.ajax({
                url : '/coursemgmt/courses',
                type : 'GET',
                async : false,
                success : function(data) {
                    console.log(data);
                },
                error : function(returndata) {
                    console.log("error");
                }
            });
        })
    }
</script>